<?php
		require_once("alipay.config.php");
		require_once("lib/alipay_notify.class.php");
		
		//计算得出通知验证结果
		$alipayNotify = new AlipayNotify($alipay_config);
		
		$str=serialize($_POST);
		
		$verify_result = $alipayNotify->verifyNotify();

//a:23:{s:8:"discount";s:4:"0.00";s:12:"payment_type";s:1:"1";s:7:"subject";s:18:"玛咖原果275克";s:8:"trade_no";s:28:"2015081900001000630077789710";s:11:"buyer_email";s:11:"15038259021";s:10:"gmt_create";s:19:"2015-08-19 17:51:19";s:11:"notify_type";s:17:"trade_status_sync";s:8:"quantity";s:1:"1";s:12:"out_trade_no";s:20:"20150819175108743148";s:9:"seller_id";s:16:"2088911832850294";s:11:"notify_time";s:19:"2015-08-19 18:05:31";s:4:"body";s:18:"玛咖原果275克";s:12:"trade_status";s:13:"TRADE_SUCCESS";s:19:"is_total_fee_adjust";s:1:"N";s:9:"total_fee";s:4:"0.01";s:11:"gmt_payment";s:19:"2015-08-19 17:51:19";s:12:"seller_email";s:17:"2789895025@qq.com";s:5:"price";s:4:"0.01";s:8:"buyer_id";s:16:"2088502438044635";s:9:"notify_id";s:34:"d5e0df2af4b1a420a0c1c2cc5eb839895i";s:10:"use_coupon";s:1:"N";s:9:"sign_type";s:3:"RSA";s:4:"sign";s:172:"MJKzL1J2a64kdiPkKwZwcqa1TOusLdqYLWG/5M1RQYhrMZxGWy0N9olVFMGIznulvdtMgGD5R8yS4G1AiS4p6JmsMKDK+a1gR4eEtLN7ZGWlAC8KcQMzH6jC3dbT8p4fHOSc+dDnFug+zzGU6ildOzyOZ6MTr8V4Uo/MsCTYN1Q=";}
//a:23:{s:8:"discount";s:4:"0.00";s:12:"payment_type";s:1:"1";s:7:"subject";s:18:"玛咖原果275克";s:8:"trade_no";s:28:"2015081900001000630077789710";s:11:"buyer_email";s:11:"15038259021";s:10:"gmt_create";s:19:"2015-08-19 17:51:19";s:11:"notify_type";s:17:"trade_status_sync";s:8:"quantity";s:1:"1";s:12:"out_trade_no";s:20:"20150819175108743148";s:9:"seller_id";s:16:"2088911832850294";s:11:"notify_time";s:19:"2015-08-19 17:51:19";s:4:"body";s:18:"玛咖原果275克";s:12:"trade_status";s:13:"TRADE_SUCCESS";s:19:"is_total_fee_adjust";s:1:"N";s:9:"total_fee";s:4:"0.01";s:11:"gmt_payment";s:19:"2015-08-19 17:51:19";s:12:"seller_email";s:17:"2789895025@qq.com";s:5:"price";s:4:"0.01";s:8:"buyer_id";s:16:"2088502438044635";s:9:"notify_id";s:34:"d5e0df2af4b1a420a0c1c2cc5eb839895i";s:10:"use_coupon";s:1:"N";s:9:"sign_type";s:3:"RSA";s:4:"sign";s:172:"RWE/Y3jURAyp7REJHRMy/Z1UwUcPEo0b+3+ve6PZS5hms4Mlam7cdJfamW6G/NLBOdRzeE6kDhVH037AWP+tsxGxnQqtPNIgZHW3ZNHeRnYcF5Ri/Wb5hq3NAj1lO/xTK76xHJwbMl1F7N83hZVapFQUw8lUr4BTfcJOfircRlw=";}		
//a:23:{s:8:"discount";s:4:"0.00";s:12:"payment_type";s:1:"1";s:7:"subject";s:18:"玛咖原果275克";s:8:"trade_no";s:28:"2015081900001000630077789499";s:11:"buyer_email";s:11:"15038259021";s:10:"gmt_create";s:19:"2015-08-19 17:48:46";s:11:"notify_type";s:17:"trade_status_sync";s:8:"quantity";s:1:"1";s:12:"out_trade_no";s:20:"20150819174835668175";s:9:"seller_id";s:16:"2088911832850294";s:11:"notify_time";s:19:"2015-08-19 17:48:47";s:4:"body";s:18:"玛咖原果275克";s:12:"trade_status";s:13:"TRADE_SUCCESS";s:19:"is_total_fee_adjust";s:1:"N";s:9:"total_fee";s:4:"0.01";s:11:"gmt_payment";s:19:"2015-08-19 17:48:47";s:12:"seller_email";s:17:"2789895025@qq.com";s:5:"price";s:4:"0.01";s:8:"buyer_id";s:16:"2088502438044635";s:9:"notify_id";s:34:"ef295037140f5d6fb74e2d1d2602f3e95i";s:10:"use_coupon";s:1:"N";s:9:"sign_type";s:3:"RSA";s:4:"sign";s:172:"nH23OND2hBARFwx0Soi5brEY/qc4tWOYObbBgPTxx7CpyywnfzzoxhKOJfCPd3LeWx7ojnwTf9bGIu2zb9eW61QoDsySm9Mph3ObKNwPKt5gwbvGvHlK/4SVzBbeDKpk0JqmkJQyNwkh1xW8T56CS/Xoa8S0XJrGHgmoPFdWKFg=";}
		//$arr=unserialize(serialize($_POST));
		
		if($verify_result) 
		{//验证成功
			//file_put_contents('b.txt', 'ccccc');
			/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
			//请在这里加上商户的业务逻辑程序代
			
			//——请根据您的业务逻辑来编写程序（以下代码仅作参考）——
			
		    //获取支付宝的通知返回参数，可参考技术文档中服务器异步通知参数列表
			
//			//商户订单号
//			$out_trade_no = $_POST['out_trade_no'];
//		
//			//支付宝交易号
//			$trade_no = $_POST['trade_no'];
//		
//			//交易状态
//			$trade_status = $_POST['trade_status'];
//		
//			$data['out_trade_no']=$out_trade_no;//订单号
//			$data['trade_no']=$trade_no;//交易号
//			$data['trade_status']=$trade_status;//交易状态
//			
//			$str=urlencode(serialize($data));

			$str=urlencode($str);
			//file_put_contents('b.txt', 'dddd');
			//payment_id=5表明为支付宝即时到账
			$url="http://www.mwantu.com/index.php?con=Paym&act=index&str={$str}&payment_id=9";
			//header("Location:{$url}");//支付宝不允许这样做
			//只能用curl模拟curl访问某个控制器了
//			$curl = curl_init();
//			curl_setopt($curl, CURLOPT_URL, $url);
//			curl_setopt($curl, CURLOPT_HEADER, 1);
//			curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
//			$data = curl_exec($curl);
//			curl_close($curl);
	
			
			
			$curl = curl_init();
			curl_setopt($curl, CURLOPT_URL, $url);
			curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
			curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 60);  
			$data = curl_exec($curl);
			echo $data;
		}
		else 
		{
		    //验证失败
		    echo "fail";
		
		    //调试用，写文本函数记录程序运行情况是否正常
		    //logResult("这里写入想要调试的代码变量值，或其他运行的结果记录");
		}
?>